<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Task Submission</title>
</head>
<body>
<h1>Submit a Task</h1>
<form id="taskForm">
    <label for="taskData">Enter Task Data:</label>
    <input type="text" id="taskData" name="taskData" required>
    <button type="submit">Submit</button>
</form>

<script>
    document.getElementById('taskForm').addEventListener('submit', function(event) {
        event.preventDefault();
        const taskData = document.getElementById('taskData').value;

        fetch('/submit-task', {
            method: 'POST',
            headers: {
                'Content-Type': 'application/json'
            },
            body: JSON.stringify({ taskData: taskData })
        })
            .then(response => response.json())
            .then(data => {
                alert('Task submitted successfully! Task ID: ' + data.taskId);
            })
            .catch(error => {
                console.error('Error:', error);
            });
    });
</script>
</body>
</html>